<?php
/**
 * Created by PhpStorm.
 * User: 图图
 * Date: 2021-6-11
 * Time: 14:54
 */

namespace app\common\model;

use think\Model as ThinkModel;

/**
 *  技师项目关联  模型
 **/
class UserProject extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $name = 'qt_user_project';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;


    /**
     *  获取项目关联下技师列表
     **/
    public function getEngineer($project_id = 0)
    {
        $where[] = ['project_id', 'eq', $project_id];
        $list = $this->alias('up')
            ->field('u.id,u.real_name,u.avatar,u.sign')
            ->leftJoin('qt_users u', 'u.id = up.engineer_id')
            ->where($where)
            ->order('id desc')
            ->group('engineer_id')
            ->select();
        if ($list) {
            foreach ($list as $k => $v) {
                $list[$k]['stars'] = 0;
                $list[$k]['avatar'] = checkAvatar($v['avatar']);
            }
        }

        return $list;
    }


}